package com.ls.mysql.dao;

import com.ls.mysql.entity.YzSurplus;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import javax.annotation.Generated;
import java.util.Map;

/*
 * 钱包方法接口
 */
@Mapper
@Component
public interface SurplusDao {
    //初始化用户余额
    @Insert("insert into yz_surplus(id, surplus) values(#{user_id},#{surplus})")
    public int InitSurplus(@Param("user_id") String user_id, @Param("surplus") String surplus);
    //批量初始化用户余额
    @Insert({"<script>",
            "   insert into yz_surplus(id, surplus)",
            "   values",
            "   <foreach collection=\"map.entrySet()\" index=\"key\" item=\"value\" separator=\",\">",
            "       (#{key},#{value})",
            "   </foreach>",
            "</script>"})
    public int BatchInit(@Param("map") Map<String, Object> surpluses);
    //根据id修改余额

    //根据id查询余额
    @Select("select * from yz_surplus s where s.id=#{id}")
    public YzSurplus querySurplusById(String id);

}
